<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<script>
    $(function () {
        $("#hisDiagnosisTable").treeTable({expandLevel: 2});
    })

    //添加诊断 弹出右
    $("#addDiagnosis").on('click', function () {
        hideShowTableTd('contentTable', '5,6', '2');
        $("#LeftDiv").attr("class", "main-content col-lg-8");
        $("#RightDiv").show('normal');
        return loadDiv('rigthCenterDiv', '${ctx}/doctor/hisDiagnosis/form?visitId=${visitId}&patientId=${patientId}');
    })

    //删除诊断
    $("#deleteDiagnosis").on('click', function () {
        var id = $("#id").val();
        if (id == "") {
            toastr.error('请先选择诊断');
        } else {
            delLoad('rigthDoctorCenterDiv', '${ctx}/doctor/hisDiagnosis/delete?id=' + id, '${ctx}/doctor/hisDiagnosis/index?visitId=${visitId}&patientId=${patientId}');
            //return loadDiv('rigthDoctorCenterDiv','${ctx}/doctor/hisDiagnosis/delete?id='+id);
        }
    })

    function selectDiagnosis(id, parentId) {
        $("#id").val(id);
        $("#parentId").val(parentId);
    }

    //修改诊断 弹出右
    $("#rightUpdate").on('click', function () {
        var id = $("#id").val();
        var parentId = $("#parentId").val();
        if (id == "") {
            toastr.error('请先选择诊断');
        } else {
            hideShowTableTd('contentTable', '5,6', '2');
            $("#LeftDiv").attr("class", "main-content col-lg-8");
            $("#RightDiv").show('normal');
            return loadDiv('rigthCenterDiv', '${ctx}/doctor/hisDiagnosis/form?id=' + id + '&parentId=' + parentId);
        }
    })
    //添加子诊断
    $("#addSonDiagnosis").on('click', function () {
        var parentId = $("#id").val();
        if (parentId == "" || parentId == null) {
            toastr.error('请先选择诊断');
        } else {
            hideShowTableTd('contentTable', '5,6', '2');
            $("#LeftDiv").attr("class", "main-content col-lg-8");
            $("#RightDiv").show('normal');
            return loadDiv('rigthCenterDiv', '${ctx}/doctor/hisDiagnosis/form?visitId=${visitId}&parentId=' + parentId);
        }
    })

</script>
<div class="app">
    <section class="layout">
        <section class="main-content col-lg-12" id="LeftDiv">
            <div class="content-wrap">
                <div class="wrapper" style="bottom: 50px;">
                    <section class="panel panel-default">
                        <div class="panel-body">
                            <div class="form-group">
                                <input class="btn btn-primary" type="button" value="添加诊断" id="addDiagnosis"/>
                                <%--<input class="btn btn-primary" type="button" value="添加子诊断" id="addSonDiagnosis"/>--%>
                                <input class="btn btn-primary" type="button" value="编辑" id="rightUpdate"/>
                                <input class="btn btn-primary" type="button" value="删除" id="deleteDiagnosis"/>
                            </div>
                            <div class="table-responsive no-border">
                                <input type="hidden" id="id">
                                <input type="hidden" id="parentId">
                                <input type="hidden" id="patientId">
                                <table id="hisDiagnosisTable" class="table table-bordered mg-t datatable">
                                    <thead>
                                    <tr>
                                        <th style="width: 8%;">诊断类型</th>
                                        <th style="width: 7%;">诊断描述</th>
                                        <th style="width: 5%;">治疗效果</th>
                                        <th style="width: 7%;">入院诊断</th>
                                        <th style="width: 7%;">ICD码</th>
                                        <th style="color:red;width: 7%;">M码</th>
                                        <th style="width: 4%;">手术</th>
                                        <th style="width: 7%;">诊断日期</th>
                                        <th style="width: 7%;">病理号</th>
                                        <th style="width: 7%;">疾病ICD名称</th>
                                        <th style="width: 7%;">肿瘤ICD名称</th>
                                        <th>病理诊断</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <c:forEach items="${treeList}" var="hisDiagnosis" varStatus="count">
                                        <c:choose>
                                            <c:when test="${!empty hisDiagnosis.parent.id}">
                                                <tr onclick=selectDiagnosis('${hisDiagnosis.id}','${hisDiagnosis.parent.id}')
                                                id='${hisDiagnosis.id}' pId='${hisDiagnosis.parent.id}'>
                                            </c:when>
                                            <c:otherwise>
                                                <tr id='${hisDiagnosis.id}'
                                                onclick=selectDiagnosis('${hisDiagnosis.id}','${hisDiagnosis.parent.id}')>
                                            </c:otherwise>
                                        </c:choose>
                                        <td>
                                                <%--${fns:getDictLabel(hisDiagnosis.type,"DIAGNOSIS_TYPE" ,"" )}--%>
                                            <c:choose>
                                                <c:when test="${hisDiagnosis.visitId != '' && hisDiagnosis.visitId != null}">
                                                    ${fns:getDictLabel(hisDiagnosis.type,"DIAGNOSIS_TYPE" ,"" )}
                                                </c:when>
                                                <c:otherwise>
                                                    门诊诊断
                                                </c:otherwise>
                                            </c:choose>
                                        </td>
                                        <td>${hisDiagnosis.description}</td>
                                        <td>${fns:getDictLabel(hisDiagnosis.effect,"TREATMENT_TYPE" ,"" )}</td>
                                        <td></td>
                                        <td>${hisDiagnosis.icdCode}</td>

                                        <c:choose>
                                            <c:when test="${fn:substring(hisDiagnosis.icdCode,0,1) == 'M'}">
                                                <td style="color:red;"> ${hisDiagnosis.icdCode}</td>
                                            </c:when>
                                            <c:otherwise>
                                                <td></td>
                                            </c:otherwise>
                                        </c:choose>
                                        </td>

                                        <td>${fns:getDictLabel(hisDiagnosis.operation,"YES_NO" ,"" )}</td>
                                        <td><fmt:formatDate value="${hisDiagnosis.createDate}" pattern="yyyy-MM-dd"
                                                            type="date" dateStyle="long"/></td>
                                        <td></td>
                                        <td>${hisDiagnosis.icdName}</td>
                                        <td><c:if test="${fn:contains(hisDiagnosis.icdName,'肿瘤')}">
                                            ${hisDiagnosis.icdName}</c:if></td>
                                        <td>${hisDiagnosis.pathologicDiagnosis}</td>
                                        </tr>
                                    </c:forEach>
                                    </tbody>
                                </table>
                                <div class="pagination">${page}</div>
                            </div>
                        </div>
                    </section>
                </div>
            </div>
        </section>

        <%--右侧诊疗项目列表--%>
        <section class="main-content col-lg-4" style="display: none" id="RightDiv">
            <div class="content-wrap" id="rigthCenterDiv">
            </div>
        </section>
    </section>

</div>

